<%--
  Created by IntelliJ IDEA.
  User: m1870
  Date: 2020/5/1
  Time: 20:41
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <title>
    删除积分
  </title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="format-detection" content="telephone=no">
  <link rel="stylesheet" href="../../../backstage/css/x-admin.css" media="all">
</head>
<body>
<div class="z-body">
  <form class="layui-form">

    <div class="layui-form-item">
      <label for="userId" class="layui-form-label">
        <span class="x-red">*</span>用户ID
      </label>
      <div class="layui-input-inline">
        <input type="text" id="userId" name="userId" required="" lay-verify="required" autocomplete="off"  class="layui-input"
               maxlength="10" onkeyup="value=this.value.replace(/\D+/g,'')" disabled>
      </div>
    </div>
    <div class="layui-form-item">
      <label for="editCredit" class="layui-form-label">
        <span class="x-red">*</span>积分删除值
      </label>
      <div class="layui-input-inline">
        <input type="number" id="editCredit" name="editCredit" required=""  lay-verify="required" autocomplete="off" class="layui-input" oninput = "if(value>99999)value=99999;value=value.replace(/[^\d]/g,'')">
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">
      </label>
      <input type="button" id="delete"value="删除" class="layui-btn" lay-filter="save" lay-submit="delete">
      </input>
    </div>
  </form>
</div>
<script src="../../../backstage/lib/layui/layui.js" charset="utf-8"></script>
<script src="../../../backstage/js/x-layui.js" charset="utf-8"></script>
<script>
  layui.use(['form','layer'], function() {
    $ = layui.jquery;
    var form = layui.form();
    layer = layui.layer;




    form.verify({
      editCredit: function (value) {
        if (value.length <= 0) {
          return '积分值不能为空';
        }
      }

    });
    $(document).ready(function () {
      //获取传递过来的localStorage
      var id = window.localStorage.getItem('msg');
      $("#userId").val(id);

      //积分删除
      $("#delete").click(function () {
//      var userId = $.trim($("#userId").val());
        var editCredit = $.trim($("#editCredit").val());
        console.log(id);
        console.log(editCredit);

        $.ajax({
          type: 'POST',
          url: '/credit/delete',
          dataType: "json",
          data: {uid: id, deleteCredit: editCredit},
          error: function () {
            alert("失败");
          },
          success: function (data) {
            if (data.message == "已删除") {
              alert("删除成功！");
            } else if (data.message == "用户不存在") {
              alert("用户不存在，无法操作");
            } else if("删除积分大于用户积分"){
              alert("删除积分大于用户积分,无法操作")
            }
            location.reload();
          }
        });
      });
    });
  });
</script>
</body>
</html>
